package com.smarthealthring.mm.widgets;

import android.content.Context;
import android.support.v4.view.ViewPager;
import android.util.AttributeSet;
import android.view.MotionEvent;

/**
 * 不可手势滑动的ViewPager
 * <p>
 * Created by sunxl8 on 2017/6/27.
 */

public class NoScroolViewPager extends ViewPager {

    boolean isScrollable = false;

    public NoScroolViewPager(Context context) {
        super(context);
    }

    public NoScroolViewPager(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    @Override
    public boolean onTouchEvent(MotionEvent ev) {
        return isScrollable && super.onTouchEvent(ev);
    }

    @Override
    public boolean onInterceptTouchEvent(MotionEvent ev) {
        return isScrollable && super.onInterceptTouchEvent(ev);
    }

    public void setScrollable(boolean isScrollable) {
        this.isScrollable = isScrollable;
    }
}
